package com.hanserwei.mydemo.stream;

import java.util.stream.Stream;

public class SplitTest1 {
    public static void main(String[] args) {
        // 1.合并
        Stream<Integer> a = Stream.of(1, 2, 3);
        Stream<Integer> b = Stream.of(4, 5, 6);
        Stream<Integer> stream = Stream.concat(a, b);

        /*
         * 2.截取
         * skip(long n) 跳过前n个元素，保留剩下的元素
         * limit(long n) 截取前n个元素，剩余的元素丢弃
         * */

        // 截取中间3，4，5
        Stream.of(1, 2, 3, 4, 5, 6).skip(2).limit(3).forEach(System.out::print);
    }
}
